use eframe::egui;

pub fn menucreate(
    ui: &mut egui::Ui,
    _ma: &mut crate::MyEguiApp,
) -> egui::InnerResponse<Option<()>> {
    //文件菜单
    ui.menu_button("文件", |ui| {
        if ui.button("新建").clicked() {};
        if ui.button("打开").clicked() {
            ui.close_menu()
        };
        if ui.button("保存").clicked() {};
        if ui.button("退出").clicked() {
            ui.close_menu();
            ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
        }
    });
    //选项菜单
    ui.menu_button("选项", |ui| if ui.button("选项1").clicked() {});
    //设置菜单
    ui.menu_button("设置", |ui| {
        if ui.button("设置").clicked() {}
        let imgfile = egui::include_image!("../icons/icon.png");
        if ui
            .add(egui::Button::image_and_text(
                egui::Image::new(imgfile),
                "保存",
            ))
            .clicked()
        {}
    });
    //工具菜单
    ui.menu_button("工具", |ui| if ui.button("工具").clicked() {});
    //帮助菜单
    ui.menu_button("帮助", |ui| {
        if ui.button("关于").clicked() {
            ui.close_menu();
        }
        if ui.button("此软件").clicked() {
            ui.close_menu();
        }
    })
}
